FROM php:7.4-fpm-alpine

MAINTAINER dracoqiu 1776658191@qq.com




# 执行 docker-php-source extract 命令会把所有PHP扩展源码扩展存放到 /usr/src/php/ext
# ---------------------------------------------------------------
# -------------------------- 可安装扩展 --------------------------
# ---------------------------------------------------------------
# bcmath
# bz2
# calendar
# com_dotnet
# ctype
# curl
# date
# dba
# dom
# enchant
# exif
# ffi
# fileinfo
# filter
# ftp
# gd
# gettext
# gmp
# hash
# iconv
# imap
# intl
# json
# ldap
# libxml
# mbstring
# mysqli
# mysqlnd
# oci8
# odbc
# opcache
# openssl
# pcntl
# pcre
# pdo
# pdo_dblib
# pdo_firebird
# pdo_mysql
# pdo_oci
# pdo_odbc
# pdo_pgsql
# pdo_sqlite
# pgsql
# phar
# posix
# pspell
# readline
# reflection
# session
# shmop
# simplexml
# skeleton
# snmp
# soap
# sockets
# sodium
# spl
# sqlite3
# standard
# sysvmsg
# sysvsem
# sysvshm
# tidy
# tokenizer
# xml
# xmlreader
# xmlrpc
# xmlwriter
# xsl
# zend_test
# zip
# zlib


# 下载目录
ENV DOWNLOAD_DIR /var/downloads
# PHP扩展源码的存放目录
ENV SOURCE_DIR /usr/src/php/ext


# 替换国内源
RUN cp /etc/apk/repositories /etc/apk/repositories_bak \
    && sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories \
    
    # 更新安装依赖包和PHP核心拓展
    && apk update \
    && apk add m4 libbz2 perl autoconf pkgconf dpkg-dev dpkg libmagic file libgcc libstdc++ binutils \
            libgomp libatomic libgphobos gmp isl22 mpfr4 mpc1 gcc musl-dev libc-dev g++ make re2c \
    
    # GD库必须的依赖
    && apk add zlib-dev libpng-dev libwebp-dev libjpeg libjpeg-turbo-dev freetype-dev \


    # 安装 Composer
    ## && curl -sS https://install.phpcomposer.com/installer | php -- --install-dir=/usr/local/bin --filename=composer
    && curl -sS https://getcomposer.org/installer | php && mv composer.phar /usr/local/bin/composer \

    # 创建并初始化 /usr/src/php目录
    && docker-php-source extract \

    # 安装gd库
    && docker-php-ext-configure gd --with-freetype --with-webp --with-jpeg \
    && docker-php-ext-install gd \

    # 安装mysqli
    && docker-php-ext-install mysqli \

    # 安装pdo_mysql
    && docker-php-ext-install pdo_mysql \

    # 安装Redis  参数retry 重试5次
    && curl --retry 5 -o redis-5.3.7.tgz https://pecl.php.net/get/redis-5.3.7.tgz \
    && pecl install redis-5.3.7.tgz && docker-php-ext-enable redis \

    # 安装memcached扩展所需的依赖扩展
    && apk add libmemcached-dev \

    # 安装memcached扩展  参数retry 重试5次
    && curl --retry 5 -o memcached-3.2.0.tgz https://pecl.php.net/get/memcached-3.2.0.tgz \
    && pecl install memcached-3.2.0.tgz && docker-php-ext-enable memcached \

    # 安装memcache扩展  参数retry 重试5次
    && curl --retry 5 -o memcache-4.0.5.2.tgz https://pecl.php.net/get/memcache-4.0.5.2.tgz \
    && pecl install memcache-4.0.5.2.tgz && docker-php-ext-enable memcache

    
